package com.sheng.filter;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;


public class Producer1 {
    public static void main(String[] args) throws Exception {
        //1.创建一个发送消息的对象Producer
        DefaultMQProducer producer = new DefaultMQProducer("group");
        //2.设定发送的命名服务器地址
        producer.setNamesrvAddr("localhost:9876");
        //3.启动发送的服务
        producer.start();
        //发送批量消息

            //4.创建要发送的消息对象,指定topic,指定内容body
            Message msg = new Message("topic2",(" 属性过滤1:hello rocketmq").getBytes("UTF-8"));
//            //设置当前消息的延时效果
//            msg.setDelayTimeLevel(3);
        msg.putUserProperty("vip","22");
        msg.putUserProperty("vip","30");

            //发送消息
            SendResult result = producer.send(msg);
            System.out.println(result);
            System.out.println("返回结果: " + result);

        //关闭连接
        producer.shutdown();

    }
}